<?php
/*
*作者:liuleyi
*功能描述:供应商控制器
*修改记录
*修改时间   修改人     修改描述
*/
namespace Admin\Controller;
use Think\Controller;
class VendorController extends  Controller{

    public function  add(){
        if (!empty($_POST)) {

            $func = new \Admin\Func\Func904010101(I(VAR_VENDORID),I(VAR_VENDORSHORTNAME),I(VAR_VENDORFULLNAME),I(VAR_VENDORADDRESS),I(VAR_VENDORRESPNAME),I(VAR_VENDORRESPPHONENO),I(VAR_VENDORRESPMOBILEPHONENO));

            if ($func->execute() === false) {
                $this->error("新增失败:" . $func->getErrMsg());
            } else {
                // $this->display();
                $this->success('新增成功！');
            }
            //  $this->display();
        } else {
            $this->display();
        }
    }

    public function  del($VendorID){
        $func = new \Admin\Func\Func904010103($VendorID);
        if ($func->execute() === false) {
            $this->error('删除失败' . $func->getErrMsg());
        } else {
            $this->redirect('Vendor/lst');
        }
    }

    public function  edit($VendorID){
        if (!empty($_POST)) {
            $func = new \Admin\Func\Func904010102(I(VAR_VENDORID),I(VAR_VENDORSHORTNAME),I(VAR_VENDORFULLNAME),I(VAR_VENDORADDRESS),I(VAR_VENDORRESPNAME),I(VAR_VENDORRESPPHONENO),I(VAR_VENDORRESPMOBILEPHONENO));
            if ($func->execute() === false) {
                $this->error("编辑失败:" . $func->getErrMsg());
            } else {
                $this->success('编辑成功！');
            }
        } else {

            $func = new \Admin\Func\Func904010104($VendorID);
            if ($func->execute() === false) {
                $this->error('查询失败:' . $func->getErrMsg());
            } else {
                $this->assign(POST, $func->getRst()[0]);
                $this->display();
            }
        }
    }

    public function  lst(){
      $func = new \Admin\Func\Func904010105(I(VAR_VENDORSHORTNAME),I(VAR_VENDORFULLNAME),I(VAR_VENDORADDRESS),I(VAR_VENDORRESPNAME));
        if ($func->execute() === false) {
            $this->error('查询失败:' . $func->getErrMsg());
        } else {
            $location = new \Admin\Func\Func999010102(VAR_904010105);
            $location->execute();
            $this->assign(LOCATION, $location->getRst());
            $this->assign(GV_ENUM, $GLOBALS[GV_ENUM]);
            $this->assign(LST, $func->getRst());
        }
        $this->display();
    }

}
